<?php

import("data.db.DbAbstractTable");
import("data.db.DbFactory");
import("data.logic.system.Site");

class DbSite extends DbAbstractTable {
	
	var $className = "data.logic.system.Site";
	const CLASS_NAME = "data.logic.system.Site";
	
	//
	// SQL Table description section
	//
	const TB_TABLENAME	= "pd_site";
	const TB_I			= 'site';
	
	const TB_NAME		= 'site_name';
	const TB_HOST		= 'site_host';
	const TB_CAPTION	= 'site_caption';
	
	function _get_TABLENAME() {return self::TB_TABLENAME;}
	function _get_ID() {return self::TB_I."_id";}
	function _get_SUFFIX() {return self::TB_I;}
	//
	//
	
	var $name		= null;
	var $host		= null;
	var $caption	= null;

	
	public function __construct($noinit=false) {
		parent::__construct($noinit);
	}
	
	function setName($name) {
		$this->name = $name;
	}
	function getName() {
		return $this->name;
	}
	
	function setHost($host) {
		$this->host = $host;
	}
	function getHost() {
		return $this->host;
	}
	
	function setCaption($val) {
		$this->caption = $val;
	}
	function getCaption() {
		return $this->caption;
	}
	
	// restore
	function fillEntity($arrResult) {
		parent::fillEntity($arrResult);
		$this->setName($arrResult[self::TB_NAME]);
		$this->setHost($arrResult[self::TB_HOST]);
		$this->setCaption($arrResult[self::TB_CAPTION]);
	}
	
	//store
	function fillFields() {
		parent::fillFields();
		$this->fildsForStore[self::TB_NAME] = "'".$this->getName()."'";
		$this->fildsForStore[self::TB_HOST] = "'".$this->getHost()."'";
		$this->fildsForStore[self::TB_CAPTION] = "'".$this->getCaption()."'";
	}
	
	function findByRealName($name) {
		return parent::__selectByCriteria(
			self::TB_RL_NAME."='".$name."'", $this->getClassName());
	}
	
	// same for all classes
    public static function findAll() {return parent::findAll(self::CLASS_NAME);}
    public static function findById($id) {return parent::findById($id, self::CLASS_NAME);}
}

?>